/*	
	
	Copyright (c) 2007-2009 Ryan Christiansen
	
	This software is provided 'as-is', without any express or implied
	warranty. In no event will the authors be held liable for any damages
	arising from the use of this software.
	
	Permission is granted to anyone to use this software for any purpose,
	including commercial applications, and to alter it and redistribute it
	freely, subject to the following restrictions:
	
	1. The origin of this software must not be misrepresented; you must not
	claim that you wrote the original software. If you use this software
	in a product, an acknowledgment in the product documentation would be
	appreciated but is not required.
	
	2. Altered source versions must be plainly marked as such, and must not be
	misrepresented as being the original software.
	
	3. This notice may not be removed or altered from any source
	distribution.
	
*/
package funit.framework
{
	import funit.errors.AssertionError;
	import funit.framework.writers.MessageWriter;
	
	public class LegacyAssert
	{
		
		/**
		 * @param condition
		 * @param message
		 * @param messageParameters
		 */
		public static function isTrue( condition:Boolean, message:String = "", ... messageParameters ) : void
		{
			Assert.isTrue(condition, message, messageParameters);
		}
		
		/**
		 * @param condition
		 * @param message
		 * @param messageParameters
		 */
		public static function isFalse( condition:Boolean, message:String = "", ... messageParameters ) : void
		{
			Assert.isFalse(condition, message, messageParameters);
		}
		
		/**
		 * @param expected
		 * @param actual
		 * @param message
		 * @param messageParameters
		 */
		public static function areEqual( expected:Object, actual:Object, message:String = "", ... messageParameters ) : void
		{
			if ( expected != actual )
			{
				var writer:MessageWriter = new MessageWriter( message, messageParameters );
				writer.writeExpectedLine(expected);
				writer.writeActualLine(actual);
				
				throw new AssertionError( writer.toString() );
			}
		}
		
		/**
		 * @param expected
		 * @param actual
		 * @param message
		 * @param messageParameters
		 */
		public static function areNotEqual( expected:Object, actual:Object, message:String = "", ... messageParameters ) : void
		{
			if ( expected == actual )
			{
				var writer:MessageWriter = new MessageWriter( message, messageParameters );
				writer.writeExpectedLine(expected, "not");
				writer.writeActualLine(actual);
				
				throw new AssertionError( writer.toString() );
			}
		}
		
		/**
		 * @param expected
		 * @param actual
		 * @param message
		 * @param messageParameters
		 */
		public static function areStrictEqual( expected:Object, actual:Object, message:String = "", ... messageParameters ) : void
		{
			if ( expected !== actual )
			{
				var writer:MessageWriter = new MessageWriter( message, messageParameters );
				writer.writeExpectedLine(expected);
				writer.writeActualLine(actual);
				
				throw new AssertionError( writer.toString() );
			}
		}
		
		/**
		 * @param expected
		 * @param actual
		 * @param message
		 * @param messageParameters
		 */
		public static function areNotStrictEqual( expected:Object, actual:Object, message:String = "", ... messageParameters ) : void
		{
			if ( expected === actual )
			{
				var writer:MessageWriter = new MessageWriter( message, messageParameters );
				writer.writeExpectedLine(expected, "not");
				writer.writeActualLine(actual);
				
				throw new AssertionError( writer.toString() );
			}
		}
		
		/**
		 * @param instance
		 * @param message
		 * @param messageParameters
		 */
		public static function isNull( instance:Object, message:String = "", ... messageParameters ) : void
		{
			Assert.isNull(instance, message, messageParameters);
		}
		
		/**
		 * @param instance
		 * @param message
		 * @param messageParameters
		 */
		public static function isNotNull( instance:Object, message:String = "", ... messageParameters ) : void
		{
			Assert.isNotNull(instance, message, messageParameters);
		}
		
		/**
		 * @param instance
		 * @param message
		 * @param messageParameters
		 */
		public static function isUndefined( instance:*, message:String = "", ... messageParameters ) : void
		{
			if ( instance != undefined )
			{
				fail(message, messageParameters);
			}
		}
		
		/**
		 * @param instance
		 * @param message
		 * @param messageParameters
		 */
		public static function isNotUndefined( instance:*, message:String = "", ... messageParameters ) : void
		{
			if ( instance == undefined )
			{
				fail(message, messageParameters);
			}
		}
		
		/**
		 * @param definition
		 * @param instance
		 * @param message
		 * @param messageParameters
		 */
		public static function isInstanceOf( definition:Class, instance:Object, message:String = "", ... messageParameters ) : void
		{
			Assert.isInstanceOf(definition, instance, message, messageParameters);
		}
		
		/**
		 * @param definition
		 * @param instance
		 * @param message
		 * @param messageParameters
		 */
		public static function isNotInstanceOf( definition:Class, instance:Object, message:String = "", ... messageParameters ) : void
		{
			Assert.isNotInstanceOf(definition, instance, message, messageParameters);
		}
		
		/**
		 * @param value
		 * @param message
		 * @param messageParameters
		 */
		public static function isFinite( value:Number, message:String = "", ... messageParameters ) : void
		{
			Assert.isFinite(value, message, messageParameters);
		}
		
		/**
		 * @param value
		 * @param message
		 * @param messageParameters
		 */
		public static function isNaN( value:Number, message:String = "", ... messageParameters ) : void
		{
			Assert.isNaN(value, message, messageParameters);
		}
		
		/**
		 * @param expectedGreater
		 * @param expectedLess
		 * @param message
		 * @param messageParameters
		 */
		public static function isGreater( expectedGreater:Object, expectedLess:Object, message:String = "", ... messageParameters ) : void
		{
			Assert.isGreater(expectedGreater, expectedLess, message, messageParameters);
		}
		
		/**
		 * @param expectedGreaterOrEqual
		 * @param expectedLess
		 * @param message
		 * @param messageParameters
		 */
		public static function isGreaterOrEqual( expectedGreaterOrEqual:Object, expectedLess:Object, message:String = "", ... messageParameters ) : void
		{
			Assert.isGreaterOrEqual(expectedGreaterOrEqual, expectedLess, message, messageParameters);
		}
		
		/**
		 * @param expectedLess
		 * @param expectedGreater
		 * @param message
		 * @param messageParameters
		 */
		public static function isLess( expectedLess:Object, expectedGreater:Object, message:String = "", ... messageParameters ) : void
		{
			Assert.isLess(expectedLess, expectedGreater, message, messageParameters);
		}
		
		/**
		 * @param expectedLessOrEqual
		 * @param expectedGreater
		 * @param message
		 * @param messageParameters
		 */
		public static function isLessOrEqual( expectedLessOrEqual:Object, expectedGreater:Object, message:String = "", ... messageParameters ) : void
		{
			Assert.isLessOrEqual(expectedLessOrEqual, expectedGreater, message, messageParameters);
		}
		
		/**
		 * @param message
		 * @param messageParameters
		 */
		public static function fail( message:String = "", ... messageParameters ) : void
		{
			Assert.fail(message, messageParameters);
		}
		
		/**
		 * @param message
		 * @param messageParameters
		 */
		public static function ignore( message:String = "", ... messageParameters ) : void
		{
			Assert.ignore(message, messageParameters);
		}
		
	}
	
}